package com.lzp.badminton.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lzp.badminton.model.Clubmember;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lzp.badminton.vo.ActivityClubJoin;
import com.lzp.badminton.vo.ClubUser;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author astupidcoder
 * @since 2022-02-11
 */
@Repository
public interface ClubmemberMapper extends BaseMapper<Clubmember> {
    // 联表查询 俱乐部成员
    @Select("SELECT u.user_id, u.user_name, u.user_avatar, u.nickname, u.sex, u.ball_year, c.* from user u, clubmember c WHERE c.from_user_id = u.user_id and c.to_club_id = #{clubId}")
    public List<ClubUser> getClubMemberById(Page<ClubUser> page, @Param("clubId") int clubId);
    // 联表模糊查询 俱乐部成员
    @Select("SELECT u.user_id, u.user_name, u.user_avatar, u.nickname, u.sex, u.ball_year, c.* from user u, clubmember c WHERE c.from_user_id = u.user_id and c.to_club_id = #{clubId} and u.nickname like '%' #{nickname} '%'")
    public List<ClubUser> getClubMemberInfo(Page<ClubUser> page, @Param("clubId") int clubId, @Param("nickname") String nickname);
}
